var uid, wtype;
document.addEventListener('plusready',function(){ 
	uid = plus.storage.getItem('uid');
	console.log(apiRoot+"?m=home&c=chat&a=askList&uid="+uid+"&type=doctor"); 
	$.ajax({
		type:"get",
		url:apiRoot+"?m=home&c=chat&a=askList&uid="+uid+"&type=doctor",
		dataType :'json',
		success :function(data){
//			console.log(JSON.stringify(data)); 
			if(data.length < 1){ 
				toast('暂无相关记录');
			}
			var list = '';
			$.each(data.pictext, function(k,v) {
				wtype = 1;
//				console.log(JSON.stringify(v));
				list += '<div class="mui-table-view table-view-cell bbs-ico margin-bottom-5">'+
							'<div class="overflow-h">'+
								'<i class="prescribe" mid="'+v.mem.aid+'" wtype="'+wtype+'"><img src="'+getAvatar(v.mem.avatar)+'"/></i>'+
								'<div class="testPic"  did="'+v.mem.aid+'">'+
									'<li>'+
										'<span>'+v.mem.name+'</span>'+
										'<span class="mui-h6 mui-pull-right">'+v.addtime+'</span>'+
									'</li>'+
									'<li class="mui-h6 ">'+
										'<span class="iconfont type-3">&#xe626;</span>'+
										'<span>图文聊天&nbsp;</span>'+
									'</li>'+
								'</div>'+
							'</div>'+
						'</div>';
			});
			$.each(data.tell, function(k,v) {
				wtype = 2;
//					console.log(JSON.stringify(v)); 
				list += '<div class="mui-table-view table-view-cell bbs-ico margin-bottom-5">'+
							'<div class="overflow-h">'+
								'<i class="prescribe" mid="'+v.mem.aid+'" wtype="'+wtype+'"><img src="'+getAvatar(v.mem.avatar)+'"/></i>'+
								'<div>'+
									'<li>'+
										'<span>'+v.mem.name+'</span>'+
										'<span class="mui-h6 mui-pull-right">'+v.addtime+'</span>'+
									'</li>'+
									'<li class="mui-h6 ">'+
										'<span class="iconfont type-3">&#xe645;</span>'+
										'<span>电话咨询&nbsp;</span>'+
									'</li>'+
								'</div>'+
							'</div>'+
						'</div>';
			});
			$('.askList').html(list);
			$('.testPic').unbind('tap');
			$('.testPic').on('tap',function(){
				var did = $(this).attr('did');
				goNewPage('home-chat.html', {doctorid:did});
			})
			$('.prescribe').unbind('tap');
			$('.prescribe').on('tap',function(){
				var mid = $(this).attr('mid');
				var wtype = $(this).attr('wtype');
				console.log(mid+" "+wtype);
				goNewPage('free-information-inf.html', {mid:mid,wtype:wtype});
			})
		},
		error :function(e){
			console.log(JSON.stringify(e));
			errortoast();
		}
	});
},false)